using System;
using UnityEngine;

public class StartLoadLevelWindow : MonoBehaviour
{
	public static StartLoadLevelWindow instance;

	public UITexture mapPreview;

	public UILabel levelName;

	public GameObject background;

	public GameObject panel;

	public GameObject rightAnchor;

	public GameObject leftAnchor;

	public GameObject BackgroundLock;

	public GameObject BackgroundUnlock;

	public GameObject BackgroundRespect;

	public GameObject BackgroundElite;

	public GameObject ButtonsLock;

	public GameObject ButtonsUnlock;

	public UISprite reputationBar;

	public UILabel reputationLable;

	public LevelsInfo curMapInfo;

	public UILabel timerLable;

	private void Awake()
	{
		instance = this;
	}

	public void ShowWindow(LevelsInfo info, float reputationFill = 0f, string reputation = "", bool isElite = false, DistrictState dState = DistrictState.Unlocked)
	{
		curMapInfo = info;
		mapPreview.mainTexture = Resources.Load<Texture>("Textures/LevelPreview/" + info.nameTextureForButton);
		levelName.text = info.nameLevel;
		reputationBar.fillAmount = reputationFill;
		reputationLable.text = reputation;
		timerLable.gameObject.SetActive(false);
		switch (dState)
		{
		case DistrictState.Locked:
			BackgroundElite.gameObject.SetActive(false);
			BackgroundUnlock.gameObject.SetActive(false);
			BackgroundLock.gameObject.SetActive(true);
			BackgroundElite.gameObject.SetActive(false);
			ButtonsLock.SetActive(true);
			ButtonsUnlock.SetActive(false);
			break;
		case DistrictState.Captured:
			BackgroundElite.gameObject.SetActive(false);
			BackgroundUnlock.gameObject.SetActive(false);
			BackgroundLock.gameObject.SetActive(false);
			BackgroundRespect.gameObject.SetActive(true);
			ButtonsLock.SetActive(false);
			ButtonsUnlock.SetActive(true);
			break;
		default:
			if (isElite)
			{
				BackgroundElite.gameObject.SetActive(true);
				BackgroundUnlock.gameObject.SetActive(false);
				BackgroundLock.gameObject.SetActive(false);
				BackgroundRespect.gameObject.SetActive(false);
				ButtonsLock.SetActive(false);
				ButtonsUnlock.SetActive(true);
			}
			else
			{
				BackgroundElite.gameObject.SetActive(false);
				BackgroundUnlock.gameObject.SetActive(true);
				BackgroundLock.gameObject.SetActive(false);
				BackgroundRespect.gameObject.SetActive(false);
				ButtonsLock.SetActive(false);
				ButtonsUnlock.SetActive(true);
			}
			break;
		}
		panel.SetActive(true);
		background.SetActive(true);
	}

	public void HideWindow()
	{
		background.SetActive(false);
		panel.SetActive(false);
	}

	public void UpdateTimer(float seconds)
	{
		timerLable.gameObject.SetActive(seconds > 0.9f);
		TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
		string text = string.Format("{0:D2}:{1:D2}:{2:D2}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
		timerLable.text = text;
	}

	public void LoadSelectedLevel()
	{
		controllerConnectPhoton.thisScript.connectRandomRoom(curMapInfo.nameScene, curMapInfo.modeGame);
	}
}
